﻿<!-- 基本资料 -->
<template>
    <div style="background: #f8f8f9">
        <Tabs v-model="tabName">
            <!-- 机构信息 -->
            <TabPane v-if="quanxian=='Ent'||quanxian==12" label="机构信息" name="name1">
                <Card>
                    <!-- 头部按钮 -->
                    <Row>
                        <Col span="24">
                        <Button type="primary" style="float: right;" @click="submit">修改机构信息</Button>
                        </Col>
                    </Row>
                    <div class="area">
                    <Form ref="jigouxinxi" :model="jigouxinxi" :rules="rules">
                        <p class="fon">机构证件扫描件</p>
                        <Row type="flex" justify="space-between">
                            <!-- 左侧 -->
                            <Col span="11">
                            <span class="dis">
                                <fileUpload :userOrg="quanxian" type="04"></fileUpload>
                                <!-- <template>
                                    <Upload
                                        ref="uploadL"
                                        type="drag"
                                        :on-success="handleSuccessTwo"
                                        :data= "scanningCopyDataL"
                                        with-credentials
                                        action="http://api.ahjdev.top/CertificateFile.userUpload">
                                        <div class="scanningCopy" :style="{'background-image': 'url(' + bgImgL + ')'}">
                                        </div>
                                    </Upload>
                                </template> -->
                            </span>
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 20%">机构名称</span>
                                <Input v-model="jigouxinxi.FullName"   style="width: 60%; margin-left:2%" />
                            </p>
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 20%">法定代表人</span>
                                <Input v-model="jigouxinxi.LegalRepresentative"  style="width: 60%; margin-left:2%" />
                            </p>
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 20%;">联系人</span>
                                <Input v-model="jigouxinxi.ContactName" style="width: 60%; margin-left:2%" />
                            </p>
                            <p style="margin: 15px 0">
                                <FormItem  prop="ContactPhone">
                                    <span style="display: inline-block;width: 20%;font-size:14px;">联系电话</span>
                                    <Input v-model="jigouxinxi.ContactPhone"  style="width: 60%; margin-left:2%" />
                                </FormItem>
                            </p>
                            </Col>
                            <!-- 右侧 -->
                            <Col span="11">
                            <span class="dis">
                                <fileUpload :userOrg="quanxian" type="05"></fileUpload>
                                <!-- <template>
                                    <Upload
                                        ref="uploadR"
                                        type="drag"
                                        :on-success="handleSuccessTwo"
                                        :data= "scanningCopyDataR"
                                        with-credentials
                                        action="http://api.ahjdev.top/CertificateFile.userUpload">
                                        <div class="scanningCopy" :style="{'background-image': 'url(' + bgImgR + ')'}">
                                        </div>
                                    </Upload>
                                </template> -->
                            </span>
                             <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 24%">机构名称缩写</span>
                                <Input v-model="xinyongma.NameAbbreviation"  style="width: 60%; margin-left:2%" />
                            </p>
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 24%">统一社会信用代码</span>
                                <Input v-model="jigouxinxi.LicenseNumber"  style="width: 60%; margin-left:2%" />
                            </p>
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 24%">地址</span>
                                <Input v-model="jigouxinxi.Address"  style="width: 60%; margin-left:2%" />
                            </p>
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 24%">机构资质</span>
                                  <input type="hidden" v-model="jigouxinxi.QualificationTypeTemp"/>
                                  <Input v-html="jigouxinxi.QualificationType" wrap="hard" type="textarea" :rows="4" :cols="20" style="width: 60%; margin-left:2%"/>
                                <Button @click="checkModalInfo">选择</Button>
                                <Modal v-model="checkModal" title="机构资质选择" @on-ok="checkOk">
                                  <h3>甲级报告书评价范围:</h3>
                                  <CheckboxGroup v-model="gradeA">
                                      <Checkbox v-for="item in CheckAllInfo.AMap" :key='item.Id' :label="item.Id">
                                          <span>{{item.Type}}</span>
                                      </Checkbox>
                                  </CheckboxGroup>
                                  <h3>乙级报告书评价范围:</h3>
                                  <CheckboxGroup v-model="gradeB">
                                      <Checkbox v-for="item in CheckAllInfo.BMap" :key='item.Id' :label="item.Id">
                                          <span>{{item.Type}}</span>
                                      </Checkbox>
                                  </CheckboxGroup>
                                  <h3>报告表范围:</h3>
                                  <CheckboxGroup v-model="gradeC">
                                      <Checkbox v-for="item in CheckAllInfo.CMap" :key='item.Id' :label="item.Id">
                                          <span>{{item.Type}}</span>
                                      </Checkbox>
                                  </CheckboxGroup>
                                </Modal>
                            </p>
                            </Col>
                        </Row>
                        <Row style="padding:20px 0">
                            <Col span="24" style="text-align:right">
                            <!-- 保存弹窗 -->
                            <!-- <Button type="primary" @click="dialog('success')">保存</Button> -->
                            </Col>
                        </Row>
                    </Form>

                    </div>
                </Card>
            </TabPane>
            <TabPane v-else label="机构信息" name="name1">
                <Card>
                    <!-- 头部按钮 -->
                    <Row>
                        <Col span="24">
                        <Button type="primary" style="float: right;" @click="submit" disabled>修改机构信息</Button>
                        </Col>
                    </Row>
                    <div class="area">
                    <Form ref="jigouxinxi" :model="jigouxinxi" :rules="rules">
                        <p class="fon">机构证件扫描件</p>
                        <Row type="flex" justify="space-between">
                            <!-- 左侧 -->
                            <Col span="11">
                            <fileUpload type="04"></fileUpload>
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 20%">机构名称</span>
                                <Input v-model="jigouxinxi.FullName" disabled  style="width: 60%; margin-left:2%" />
                            </p>
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 20%">法定代表人</span>
                                <Input v-model="jigouxinxi.LegalRepresentative" disabled  style="width: 60%; margin-left:2%" />
                            </p>
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 20%">联系人</span>
                                <Input v-model="jigouxinxi.ContactName" disabled style="width: 60%; margin-left:2%" />
                            </p>
                            <p style="margin: 15px 0">
                                <FormItem  prop="ContactPhone">
                                    <span style="display: inline-block;width: 20%">联系电话</span>
                                    <Input v-model="jigouxinxi.ContactPhone" disabled  style="width: 60%; margin-left:2%" />
                                </FormItem>
                            </p>
                            </Col>
                            <!-- 右侧 -->
                            <Col span="11">
                            <fileUpload type="05"></fileUpload>
                             <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 24%">机构名称缩写</span>
                                <Input v-model="xinyongma.NameAbbreviation"  style="width: 60%; margin-left:2%" disabled/>
                            </p>
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 24%">统一社会信用代码</span>
                                <Input v-model="jigouxinxi.LicenseNumber" style="width: 60%; margin-left:2%" disabled/>
                            </p>
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 24%">地址</span>
                                <Input v-model="jigouxinxi.Address"  style="width: 60%; margin-left:2%" disabled/>
                            </p>
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 24%">机构资质</span>
                                <!-- <Input v-model="jigouxinxi.QualificationType"  style="width: 60%; margin-left:2%" disabled /> -->
                                <Input v-html="jigouxinxi.QualificationType" wrap="hard" type="textarea" :rows="4" :cols="20" style="width: 60%; margin-left:2%"/>
                            </p>
                            </Col>
                        </Row>
                        <Row style="padding:20px 0">
                            <Col span="24" style="text-align:right">
                            <!-- 保存弹窗 -->
                            <!-- <Button type="primary" @click="dialog('success')">保存</Button> -->
                            </Col>
                        </Row>
                    </Form>

                    </div>
                </Card>
            </TabPane>
            <!-- 个人信息 -->
            <TabPane label="个人信息" name="name2">
                <Card>
                    <!-- 头部按钮 -->
                    <Row>
                        <Col span="24">
                        <Button type="primary" style="float: right;" @click="modifyperson">修改个人信息</Button>
                        </Col>
                    </Row>
                    <div class="area">
                    <Form ref="gerenxinxi" :model="peopledata" :rules="rules1">
                        <Row type="flex" justify="space-between">
                            <!-- 左侧 -->
                            <Col span="10">
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 20%">姓名</span>
                                <Input v-model="peopledata.RealName" style="width: 60%; margin-left:2%" disabled/>
                            </p>
                            <p>
                                <span style="display: inline-block;width: 20%">性别</span>
                                <RadioGroup  v-model="peopledata.Gender" >
                                    <Radio  label="M" disabled>
                                        <span>男</span>
                                    </Radio>
                                    <Radio  label="F" disabled>
                                        <span>女</span>
                                    </Radio>
                                </RadioGroup>
                            </p>
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 20%">职位</span>
                                <Input v-model="peopledata.Job"   style="width: 60%; margin-left:2%" disabled />
                            </p>
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 20%">所属部门</span>
                                <Input v-model="peopledata.BranchInnerCode"  style="width: 60%; margin-left:2%" disabled/>
                            </p>
                            <p style="margin: 15px 0">
                                <FormItem prop="Tel">
                                <span style="display: inline-block;width: 20%;font-size:14px;">手机号</span>
                                <Input v-model="peopledata.Tel" style="width: 60%; margin-left:2%"  />
                                </FormItem>
                                <!-- <Button class="changemob" type="primary" @click="modalphon=true">修改手机号码</Button> -->
                            </p>
                            </Col>
                            <!-- 右侧 -->
                            <Col span="10">
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 20%;float:left;margin-top:23px">头像</span>
                                <template>
                                    <div class="demo-upload-list" v-for="item in uploadList" style="margin-left:3%">
                                        <template v-if="item.status === 'finished'">
                                            <img :src="LogoFile" style="width:58px;height:58px" />
                                            <div class="demo-upload-list-cover">
                                                <Icon type="ios-eye-outline" @click.native="handleView(item.url)"></Icon>
                                                <Icon type="ios-trash-outline" @click.native="handleRemove(item)"></Icon>
                                            </div>
                                        </template>
                                        <template v-else>
                                            <Progress v-if="item.showProgress" :percent="item.percentage" hide-info></Progress>
                                        </template>
                                    </div>
                                    <Upload
                                        ref="upload"
                                        :show-upload-list="false"
                                        :default-file-list="defaultList"
                                        :on-success="handleSuccess"
                                        :format="['jpg','jpeg','png']"
                                        :max-size="20480"
                                        :data="{
                                            _Method:'PersonalInfo.uploadImage',
                                            SessionID:this.sessionId,
                                            _Uploader_TaskID: this.sessionId + '-------------------------' + new Date().getTime(),
                                            _Uploader_Total: 1,
                                        }"
                                        :on-format-error="handleFormatError"
                                        :on-exceeded-size="handleMaxSize"
                                        :before-upload="handleBeforeUpload"
                                        type="drag"
                                        with-credentials
                                        :action="shishi + 'upload.dox'"
                                        style="display: inline-block;width:58px;">
                                        <div style="width: 58px;height:58px;line-height: 58px;">
                                            <Icon type="ios-camera" size="20"></Icon>
                                        </div>
                                    </Upload>
                                    <Modal title="头像预览" v-model="visible">
                                        <img :src="LogoFile" v-if="visible" style="width: 100%">
                                    </Modal>
                                </template>
                            </p>
                            <p style="margin: 15px 0">
                                <FormItem prop="Email">
                                    <span style="display: inline-block;width: 20%;font-size:14px;">邮箱</span>
                                    <Input v-model.trim="peopledata.Email" style="width: 60%; margin-left:2%" />
                                </FormItem>
                            </p>
                            <p style="margin: 15px 0">
                                <span style="display: inline-block;width: 20%;font-size:14px;">qq</span>
                                <Input v-model="peopledata.QQ" style="width: 60%; margin-left:2%" />
                            </p>
                            <p style="margin: 15px 0">
                                <FormItem prop="Prop2">
                                    <span style="display: inline-block;width: 20%;font-size:14px;">微信</span>
                                    <Input  style="width: 60%; margin-left:2%" v-model.trim="peopledata.Prop2"/>
                                </FormItem>
                            </p>
                            </Col>
                        </Row>
                    </Form>
                    </div>
                    <Row style="padding:20px 0">
                        <Col span="24" style="text-align:right">
                        </Col>
                    </Row>
                    <Modal v-model="modalphon" title="绑定手机号" @on-ok="ok" @on-cancel="cancel">
                        <div class="phone">
                            <Input v-model="changemob" placeholder="请输入手机号" />
                        </div>
                        <div class="code">
                            <Input v-model="code" placeholder="验证码"  />
                        </div>
                    </Modal>
                </Card>
            </TabPane>
            <!-- 人员管理 -->
            <TabPane v-if="quanxian=='Ent'||quanxian==12" label="人员管理" name="name3">
                <Row :gutter="16">
                    <Col span="5">
                        <card>
                            <div slot="title">
                                <Row type="flex" justify="space-between" align="middle" class="code-row-bg">
                                    <Col > <span>组织架构</span></Col>
                                    <col><Button type="primary" @click="getbumen">创建部门</Button></cow>
                                </Row>
                            </div>
                            <Tree :data="tree" :render="renderContent1"></Tree>
                        </card>
                    </Col>
                    <Col span="19">
                        <Card>
                            <!-- 头部按钮 -->
                            <Row :gutter="8">
                                <Col span="2">
                                <Input v-model="look.realName" placeholder="关键词搜索"  />
                                </Col>
                                <Col span="2">
                                <Select v-model="look.name" clearable>
                                    <Option v-for="item in bmArr" :value="item.branchInnerCode" :key="item.branchInnerCode">{{ item.name }}</Option>
                                </Select>
                                </Col>
                                <Col span="2">
                                <Select v-model="look.position" clearable>
                                    <Option v-for="item in zwArr" :value="item.Position" :key="item.Id">{{ item.Position }}</Option>
                                </Select>
                                </Col>
                                <Col span="2">
                                <Button @click="lookUpInfo(1)" type="primary" style="width:100%" >查找</Button>
                                </Col>
                                <Col span="2">
                                <Button @click="clearInfo" type="primary" style="width:100%">清除</Button>
                                </Col>
                                <Col span="2" offset="2">
                                <Button type="primary" style="width:100%" @click="newPosition">创建职位</Button>

                                </Col>
                                <Col span="2">
                                <Button type="primary" style="width:100%" @click="addpeople=true">人员添加</Button>
                                </Col>
                            </Row>
                            <!-- 人员管理表格 -->
                            <Table border :columns="columns1" :data="data1" style="margin-top: 10px"  :loading="loading"></Table>
                            <!-- 人员管理表格的分页 -->
                            <div style="margin: 10px;overflow: hidden">
                                <div style="float: right;">
                                    <Page show-total :total='pageTotal'  @on-change='changePage' :current="page"></Page>
                                </div>
                            </div>
                        </Card>
                    </Col>
                </Row>

                <!-- 创建部门模态框  -->
                <Modal v-model="chuangjianbumen" title="" footer-hide = true>
                        <Row>
                            <Col span="12">
                            <h3>创建总公司部门</h3>
                            </Col>
                            <Col span="12">
                            <!-- <Button type="primary" style="float: right;" @click="addbumen">添加</Button> -->
                            </Col>
                        </Row>
                        <Table border :columns="columns2" :data="data2" style="margin-top: 10px"></Table>
                </Modal>

                <!-- 创建职位模态框 -->
                <Modal v-model="chuangjianzhiwei" title="创建职位">
                    <Row>
                        <Col span="12">
                        <h3>创建职位</h3>
                        </Col>
                        <Col span="12">
                        <Button @click="addBtn" type="primary" style="float: right;">添加</Button>
                        </Col>
                    </Row>
                    <Table border :columns="columns3" :data="data3" style="margin-top: 10px"></Table>
                </Modal>
                <!-- 人员添加模态框 -->
                <Modal v-model="addpeople" title="人员添加" >
                    <Form ref="formCustom" :model="formCustom" :rules="ruleCustom" :label-width="80">
                        <div style="text-align:center">
                            <Row>
                            <Col span="16">
                            <FormItem label="手机号" prop="passwd">
                            <Input  v-model="formCustom.passwd" placeholder="请输入手机号" style="width: 250px" />
                            </FormItem>
                            </Col>
                            <Col span="8">
                            <FormItem>
                            <Button type="primary" @click="searchphone">查找</Button>
                            </FormItem>
                            </Col>
                            </Row>
                        </div>
                    </Form>
                    <div class="renyuan" v-if="chuangjianrenyuan">
                        <span>该账号未创建请创建账号</span>
                        <Button type="primary" @click="chuangjianperson">创建</Button>
                    </div>
                    <div v-if="tianjiarenyuan" class="renyuan">
                        <span>该手机号是已有账号</span>
                        <Button type="primary" @click="addperson">添加</Button>
                    </div>
                </Modal>
                <!-- 人员删除 -->
                <Modal
                    v-model="deleteBtn"
                    title="提示"
                    @on-ok="deleteOk">
                    <!-- <p>{{deleteMsg}}</p> -->
                    <Input v-html="deleteMsg" wrap="hard" type="textarea" :rows="4" :cols="20" style="width: 100%; margin-left:2%"/>
                </Modal>
            </TabPane>
            <TabPane v-else label="人员管理" name="name3">
                <Row :gutter="16">
                    <Col span="5">
                        <card>
                            <div slot="title">
                                <Row type="flex" justify="space-between" align="middle" class="code-row-bg">
                                    <Col><span>组织架构</span></Col>
                                    <col><Button type="primary" @click="getbumen" disabled>创建部门</Button></cow>
                                </Row>
                            </div>
                            <Tree :data="tree" :render="renderContentquanxian"></Tree>
                        </card>
                    </Col>
                    <Col span="19">
                        <Card>
                    <!-- 头部按钮 -->
                            <Row :gutter="8">
                                <Col span="2">
                                <Input v-model.trim="look.realName" placeholder="关键词搜索"  />
                                </Col>
                                <Col span="2">
                                <Select v-model="look.name" clearable>
                                    <Option v-for="item in bmArr" :value="item.branchInnerCode" :key="item.branchInnerCode">{{ item.name }}</Option>
                                </Select>
                                </Col>
                                <Col span="2">
                                <Select v-model="look.position" clearable>
                                    <Option v-for="item in zwArr" :value="item.Position" :key="item.Id">{{ item.Position }}</Option>
                                </Select>
                                </Col>
                                <Col span="2">
                                <Button @click="lookUpInfo(1)" type="primary" style="width:100%" >查找</Button>
                                </Col>
                                <Col span="2">
                                <Button @click="clearInfo" type="primary" style="width:100%">清除</Button>
                                </Col>
                                <Col span="2" offset="2">
                                <Button type="primary" style="width:100%" @click="newPosition" disabled>创建职位</Button>

                                </Col>
                                <Col span="2">
                                <Button type="primary" style="width:100%" @click="addpeople=true" disabled>人员添加</Button>
                                </Col>
                            </Row>
                            <!-- 人员管理表格 -->
                            <Table border :columns="columnsquanxian" :data="data1" style="margin-top: 10px"  :loading="loading"></Table>
                            <!-- 人员管理表格的分页 -->
                            <div style="margin: 10px;overflow: hidden">
                                <div style="float: right;">
                                    <Page show-total :total='pageTotal' @on-change='changePage' :current.sync='page'></Page>
                                </div>
                            </div>
                        </Card>
                    </Col>
                </Row>
            </TabPane>
        </Tabs>
    </div>
</template>

<script>
    import libs from "../../libs/uploads";
    export default {
        inject: ['reload'],
        data() {
            const validatePhone = (rule, value, callback) => {
                console.log(value);
                if (!value) {
                    return callback();
                } else if (!/^((0\d{2,3}-\d{7,8})|(1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}))$/.test(value)) {
                    callback(new Error("手机号码格式不正确"));
                } else {
                    callback();
                }
            };
            const validatePass = (rule, value, callback)=>{
                if(!value){
                    return callback();
                }else if(!/^[0-9]*$/.test(value)){
                    callback(new Error("微信号只可以为数字"))
                }else {
                    callback();
                }
            };
            const validateEmail = (rule, value, callback)=>{
                if(!value){
                    return callback();
                }else if(!/^[0-9A-Za-z][\.-_0-9A-Za-z]*@[0-9A-Za-z]+(\.[0-9A-Za-z]+)+$/.test(value)){
                    callback(new Error("邮箱格式不正确"))
                }else {
                    callback();
                }
            };
            return {
                shishi:'',
                loading:false,
                deleteBtn: false,
                sessionId: '',
                formCustom: {
                    passwd: '',
                },
                ruleCustom: {
                    passwd: [
                        {validator: validatePhone,trigger: 'blur'}
                    ]
                },
                scanningCopyDataR: {
                    IdentityType : '04',
                    CertificationNo: '410327199212027040',
                    CoverOrBack: 'file',
                    Validity: '2018-07-02',
                },
                scanningCopyDataL: {
                    IdentityType : '04',
                    // CertificationNo: '410327199212027000',
                    // CoverOrBack: 'Cover',
                    // Validity: '2019-02-02',
                },
                bgImgL: '',
                bgImgR: '',
              gradeA: [],
              gradeB: [],
              gradeC: [],
              CheckAllInfo: {},
              checkModal: false,
                rules: {
                    ContactPhone:[
                        { validator: validatePhone, trigger: "blur" }
                    ]
                },
                rules1: {
                    Email: [
                        { validator: validateEmail, trigger: 'blur' }
                    ],
                    Tel:[
                        { validator: validatePhone, trigger: "blur" }
                    ],
                    // Prop2: [
                    //     {validator: validatePass, trigger: 'blur'}
                    // ]

                },
                defaultList: [
                    {
                        'name': 'a42bdcc1178e62b4694c830f028db5c0',
                        'url': 'https://o5wwk8baw.qnssl.com/a42bdcc1178e62b4694c830f028db5c0/avatar'
                    },
                ],
                imgName: '',
                visible: false,
                uploadList: [],
                look: {   //人员管理查询功能
                    realName: '',
                    name: '',
                    position: ''
                },
                jigouxinxi:{},//机构信息
                pageTotal:0,
                chuangjianrenyuan:false,
                tianjiarenyuan:false,
                tianjiaxinxi:"",
                addorbuild:'',
                addphone:"",
                tableconpany:[],
                // companydata:{},
                peopledata:{},
                xinzengrenyuan:false,
                shifoushanchu:false,
                tabName: 'name1',
                vertical: '',
                value: "",
                // modalOrganization: false,
                modalphon: false,
                chuangjianbumen:false,
                chuangjianzhiwei:false,
                addpeople:false,
                fengongsi:false,
                page:1,//人员管理表格页码
                tree: [],
                buttonProps: {
                    type: 'default',
                    size: 'small',
                },
                dataPositions: [],
                arr:'',
                infoPosition: [],
                select1:{},//人员管理结构
                changemob:'',
                code:'',
                deleteMsg: '',
                columns1RealName: null,
                columns1: [
                    {
                        title: "账号",
                        key: "mobile",
                        align: "center",
                        render: (h, params) => {
                            return h("div", [h("p",this.data1[params.index].mobile)
                            ]);
                        }
                    },
                    {
                        title: "姓名",
                        key: "realName",
                        align: "center",
                        render: (h, params) => {
                            return h("div", [h("Input",
                                {
                                    props:{
                                        // value: params.row.realName
                                        value: this.data1[params.index].realName
                                    },
                                    on: {
                                        'on-change': (value) => {
                                            this.columns1RealName = value.target.value
                                            console.log(this.data1[params.index].realName)
                                        },
                                        // 'on-blur': (val) => {
                                        //     console.log(val)
                                        //     let realName = val.target.value
                                        //     this.data1[params.index].realName = realName
                                        //     // if (val.relatedTarget.innerText) {
                                        //     //     let row = params.row
                                        //     //     row.realName = realName
                                        //     //     this.bcBtn(row)
                                        //     // }
                                        // }
                                    }
                                }
                            )]);
                        }
                    },
                    {
                        title: "性别",
                        key: "sex",
                        align: "center",
                        render: (h, params) => {
                            return h("div", [h("Select",{
                                props:{
                                //    value: params.row.sex
                                   value: this.data1[params.index].sex
                                },
                                on: {
                                    'on-change': (val) => {
                                        // params.row.sex = val
                                        this.data1[params.index].sex = val
                                        this.data1[params.index].realName = this.columns1RealName
                                    }
                                }
                            },
                            this.sexArr.map((i)=>{
                                return h("Option",{
                                    props:{
                                        value: i.value,
                                        label: i.label
                                    }
                                },i.label)
                            })
                            )]);
                        }
                    },
                    {
                        title: "所属公司",
                        key: "",
                        align: "center",
                        render: (h, params) => {
                            return h("div", [h("Select",{
                                props:{
                                    // value: params.row.gsId,
                                    // label:params.row.gs,
                                    value: this.data1[params.index].gsId,
                                    label: this.data1[params.index].gs,
                                   'label-in-value': true
                                },
                                on: {
                                    'on-change': (event)=>{
                                      console.log(event)
                                        // params.row.gsId =event.value
                                        // params.row.gs=event.label
                                        this.data1[params.index].realName = this.columns1RealName
                                        this.data1[params.index].gsId =event.value
                                        this.data1[params.index].gs =event.label
                                        axios.post('branch/findBranch',{
                                            // ParentInnerCode:params.row.gsId
                                            ParentInnerCode:event.value
                                        }).then(res=>{
                                            if(res._STATUS==1){
                                                // params.row.branchList=res.branchForCompany
                                                // console.log(params.row.brid)
                                                // params.row.brid=''
                                                // params.row.branch=''
                                                this.data1[params.index].branchList=res.branchForCompany
                                                this.data1[params.index].branchInnerCode = ''
                                                this.data1[params.index].branch = ''
                                                this.data1[params.index].positionId = ''
                                                this.data1[params.index].position = ''
                                                if(res.companyType=='0') {
                                                  this.data1[params.index].companyType = 0
                                                }else {
                                                  this.data1[params.index].companyType = 1
                                                }
                                            }else{
                                                // 如果所选公司没有部门信息时判断
                                                // params.row.branchList=[]
                                                this.data1[params.index].branchList=[]
                                                this.data1[params.index].branchInnerCode = ''
                                                this.data1[params.index].branch = ''
                                                this.data1[params.index].positionId = ''
                                                this.data1[params.index].position = ''
                                            }
                                        })
                                    }
                                }

                            },
                            this.gsArr.map((i)=>{
                                return h("Option",{
                                        props: {
                                         value: i.BranchInnerCode,
                                         label: i.Name,
                                         CompanyType: i.CompanyType
                                        },
                                    },i.Name)
                                })
                            )]);
                        }
                    },
                    {
                        title: "所属部门",
                        key: "",
                        align: "center",
                        render: (h, params) => {
                            return h("div", [h("Select",{
                                props:{
                                    // value: params.row.brId,
                                    // label:params.row.branch,
                                    value: this.data1[params.index].branchInnerCode,
                                    label: this.data1[params.index].branch,
                                    'label-in-value': true
                                },
                                on:{
                                    'on-change':(event)=>{
                                        this.data1[params.index].realName = this.columns1RealName
                                        // params.row.branchInnerCode=event.value
                                        this.data1[params.index].branchInnerCode = event.value
                                        this.data1[params.index].branch = event.label
                                    }
                                }
                            },
                            this.data1[params.index].branchList.map((i)=>{
                                return h('Option', {
                                    props: {
                                        value: i.branchInnerCode,
                                        label:i.name
                                    }
                                },i.name);
                            })
                            )]);
                        }
                    },
                    {
                        title: "职位名称",
                        key: "position",
                        align: "center",
                        render: (h, params) => {
                            return h("div", [h("Select",{
                                props:{
                                  //  value:params.row.positionId,
                                  //  label:params.row.position,
                                   value:this.data1[params.index].positionId,
                                   label:this.data1[params.index].position,
                                   'label-in-value': true
                                },
                                on: {
                                    'on-change': (event) => {
                                    this.data1[params.index].realName = this.columns1RealName
                                    // params.row.positionId = event.value
                                    // params.row.position = event.label
                                    this.data1[params.index].positionId = event.value
                                    this.data1[params.index].position = event.label
                                    }
                                }
                            },
                            this.zwArr.map((i)=>{
                                return h("Option",{
                                    props: {
                                        value: i.ParentId,
                                        label: i.Position,
                                        disabled: (this.data1[params.index].companyType==0&&i.ParentId==3?true:false)||(this.data1[params.index].companyType==1&&(i.ParentId==1||i.ParentId==2||i.ParentId==7))?true:false
                                    }
                                },i.Position)
                            })
                            )]);
                        }
                    },
                    {
                        title: "操作",
                        key: "opera",
                        align: "center",
                        render: (h, params) => {
                            return h("div",{style:{width:'155px'}}, [
                                h(
                                    "Button", {
                                        props: {
                                            type:"primary",
                                            size:"small"
                                        },
                                        style: {
                                            marginRight: "5px"
                                        },
                                        on: {
                                            click: ()=>{
                                                this.bcBtn(params.row)
                                            }
                                        }
                                    },
                                    "保存"
                                ),
                                h(
                                    "Button", {
                                        props: {
                                            type:"error",
                                            size:"small"
                                        },
                                        style: {
                                            marginRight: "5px"
                                        },
                                        on: {
                                            click: ()=>{
                                                this.$Modal.confirm({
                                                    title: '提示',
                                                    content: '<p>是否删除本员工</p>',
                                                    onOk: () => {
                                                        this.scBtn(params.row)
                                                    },
                                                    onCancel: () => {
                                                    }
                                                });
                                                
                                            }
                                        }
                                    },
                                    "删除"
                                ),
                                h(
                                    "Button", {
                                        props: {
                                            type:"warning",
                                            size:"small"
                                        },
                                        on: {
                                            click: ()=>{
                                                this.czBtn(params.row)
                                            }
                                        }
                                    },
                                    "重置密码"
                                )
                            ]);
                        }
                    }
                ],
                columnsquanxian: [//如果是二级账号就用此数据
                    {
                        title: "账号",
                        key: "mobile",
                        align: "center",
                        render: (h, params) => {
                            return h("div", [h("p",this.data1[params.index].mobile)
                            ]);
                        }
                    },


                    {
                        title: "姓名",
                        key: "realName",
                        align: "center",
                        render: (h, params) => {
                            return h("div", [h("Input",
                                {   
                                    props:{
                                        disabled:true,
                                        // value: params.row.realName
                                        value: this.data1[params.index].realName
                                    },
                                    on: {
                                        'on-blur': (val) => {
                                        // params.row.realName = val
                                            this.data1[params.index].realName = val.target.value
                                        }
                                    }
                                }
                            )]);
                        }
                    },
                    {
                        title: "性别",
                        key: "sex",
                        align: "center",
                        render: (h, params) => {
                            return h("div", [h("Select",{
                                props:{
                                    disabled:true,
                                //    value: params.row.sex
                                   value: this.data1[params.index].sex
                                },
                                on: {
                                    'on-change': (val) => {
                                        this.data1[params.index].sex = val
                                    }
                                }
                            },
                            this.sexArr.map((i)=>{
                                return h("Option",{
                                    props:{
                                        value: i.value,
                                        label: i.label
                                    }
                                },i.label)
                            })
                            )]);
                        }
                    },
                    {
                        title: "所属公司",
                        key: "",
                        align: "center",
                        render: (h, params) => {
                            return h("div", [h("Select",{
                                props:{
                                    disabled:true,
                                    value: this.data1[params.index].gsId,
                                    label: this.data1[params.index].gs,
                                   'label-in-value': true
                                },
                                on: {
                                    'on-change': (event)=>{
                                        this.data1[params.index].gsId =event.value
                                        this.data1[params.index].gs =event.label
                                        axios.post('branch/findBranch',{
                                            ParentInnerCode:params.row.gsId
                                        }).then(res=>{
                                            if(res._STATUS==1){
                                                this.data1[params.index].branchList=res.branchForCompany
                                                this.data1[params.index].branchInnerCode = ''
                                                this.data1[params.index].branch = ''
                                                this.data1[params.index].positionId = ''
                                                this.data1[params.index].position = ''
                                                if(res.companyType=='0') {
                                                  this.data1[params.index].companyType = 0
                                                }else {
                                                  this.data1[params.index].companyType = 1
                                                }
                                            }else(
                                                params.row.branchList=[]
                                            )

                                        })
                                    }
                                }

                            },
                            this.gsArr.map((i)=>{
                                return h("Option",{
                                        props: {
                                         value: i.BranchInnerCode,
                                         label: i.Name,
                                         CompanyType: i.CompanyType
                                        },
                                    },i.Name)
                                })
                            )]);
                        }
                    },
                    {
                        title: "所属部门",
                        key: "",
                        align: "center",
                        render: (h, params) => {
                            return h("div", [h("Select",{
                                props:{
                                    disabled:true,
                                    value: this.data1[params.index].branchInnerCode,
                                    label: this.data1[params.index].branch,
                                   'label-in-value': true
                                },
                                on:{
                                    'on-change':(event)=>{
                                        this.data1[params.index].branchInnerCode = event.value
                                        this.data1[params.index].branch = event.label
                                    }
                                }
                            },
                            params.row.branchList.map((i)=>{
                                return h('Option', {
                                    props: {
                                        value: i.branchInnerCode,
                                        label:i.name
                                    }
                                },i.name);
                            })
                            )]);
                        }
                    },
                    {
                        title: "职位名称",
                        key: "position",
                        align: "center",
                        render: (h, params) => {
                            return h("div", [h("Select",{
                                props:{
                                    disabled:true,
                                    value: this.data1[params.index].positionId,
                                    label: this.data1[params.index].position,
                                    'label-in-value': true
                                },
                                on: {
                                    'on-change': (event) => {
                                        this.data1[params.index].positionId = event.value
                                    }
                                }
                            },
                            this.zwArr.map((i)=>{
                                return h("Option",{
                                    props: {
                                        value: i.ParentId,
                                        label: i.Position
                                    }
                                },i.Position)
                            })
                            )]);
                        }
                    },
                    {
                        title: "操作",
                        key: "opera",
                        align: "center",
                        render: (h, params) => {
                            return h("div",{style:{width:'155px'}}, [
                                h(
                                    "Button", {
                                        props: {
                                            type:"primary",
                                            size:"small",
                                            disabled:true
                                        },
                                        style: {
                                            marginRight: "5px"
                                        },
                                        on: {
                                            click: ()=>{
                                                this.columns1RealName = null
                                                this.bcBtn(params.row)
                                            }
                                        }
                                    },
                                    "保存"
                                ),
                                h(
                                    "Button", {
                                        props: {
                                            type:"error",
                                            size:"small",
                                            disabled:true
                                        },
                                        style: {
                                            marginRight: "5px"
                                        },
                                        on: {
                                            click: ()=>{
                                                this.scBtn(params.row)
                                            }
                                        }
                                    },
                                    "删除"
                                ),
                                h(
                                    "Button", {
                                        props: {
                                            type:"warning",
                                            size:"small",
                                            disabled:true
                                        },
                                        on: {
                                            click: ()=>{
                                                this.czBtn(params.row)
                                            }
                                        }
                                    },
                                    "重置密码"
                                )
                            ]);
                        }
                    }
                ],
                // data1: [],//公司人员信息
                data1: [],                 //人员信息模拟数据
                information:[],//每个人的详细信息
                // 创建部门
                columns2: [
                    {
                        title: "部门名称",
                        key: "name3",
                        align: "center",

                        render: (h, params) => {
                            return h("div", [h("Input", {
                                props:{
                                    value:params.row.name3
                                },
                                on: {
                                    input: (event)=>{
                                        params.row.Name=event
                                        params.row.CompanyType=2
                                        params.row.Company=localStorage.getItem('company'),
                                        params.row.ParentInnerCode=localStorage.getItem('id'),
                                        params.row.Type='2',
                                        params.row.OrderFlag='0',
                                        params.row.TreeLevel='0'
                                        }
                                    }
                            })]);
                        }
                    },
                    {
                        title: "操作",
                        key: "opera1",
                        align: "center",
                        render: (h, params) => {
                            return h("div", [
                                h(
                                    "Button", {
                                        props: {
                                            type:"success",
                                            size:"small"
                                        },
                                        style: {
                                            marginRight: "5px"
                                        },
                                        on:{
                                            'click':()=>{
                                                var item = params.row
                                                this.$post('MemberBranch.add',item).then((res)=>{
                                                    console.log(res)
                                                   if(res._STATUS == 1){
                                                        this.getMenu();
                                                        this.$Message.success(res._MESSAGE);
                                                        this.chuangjianbumen=false; 
                                                   }else if(res._STATUS == 0){
                                                       this.$Message.error(res._MESSAGE);
                                                   }else{
                                                       this.$Message.error(res._MESSAGE);
                                                   }
                                                }).catch((err)=>{})

                                            }
                                        }
                                    },
                                    "保存"
                                ),
                            ]);
                        }
                    }
                ],
                data2: [{
                    name3:'',
                }
                ],
                //创建职位
                columns3: [
                    {
                        title: "职位名称",
                        key: "Position",
                        align:"center",
                        render: (h, params) => {
                            return h("div", [h("Input", {
                                    props: {
                                        type: 'text',
                                        value: params.row.Position
                                    },
                                    on: {
                                        'input': (val)=>{
                                            params.row.Position = val
                                        }
                                    }
                                })
                            ]);
                        }
                    },
                    {
                        title: "职位权限",
                        align: "center",
                        render: (h, params) => {
                            return h("div", [h("Select", {
                                    props:{
                                        value: params.row.ParentId,
                                    },
                                    on: {
                                        'on-change': (event)=>{
                                          params.row.ParentId = event
                                          // 职位权限唯一
                                          this.data3[params.index].ParentId = event
                                          // 加上防止选择清空职位名称
                                          this.data3[params.index].Position = params.row.Position
                                          this.$nextTick(()=>{
                                            this.PositionAuthority.map(ele=>{
                                              ele.disabled = false
                                            })
                                            this.data3.forEach(el=>{
                                              this.PositionAuthority=this.PositionAuthority.map(e=>{
                                                if(e.Id==el.ParentId) {
                                                  e.disabled = true
                                                }
                                                return e
                                              })
                                            })
                                          })
                                          console.log(params)
                                        }
                                    }
                                },this.PositionAuthority.map((i)=>{
                                    return h("Option",{
                                        props: {
                                            value: i.Id,
                                            label: i.Position,
                                            disabled: i.disabled
                                        }
                                    },i.Position)
                                })
                            )]);
                        }
                    },
                    {
                        title: "操作",
                        key: "opera1",
                        align: "center",
                        render: (h, params) => {
                            return h("div", [
                                h(
                                    "Button", {
                                        props: {
                                            type: "success",
                                            size: "small"
                                        },
                                        style: {
                                            marginRight: "5px"
                                        },
                                        on: {
                                            click: ()=>{
                                                this.jobAdd(params.row)
                                            }
                                        }
                                    },
                                    "保存"
                                ),
                                h(
                                    "Button", {
                                        props: {
                                            type: "error",
                                            size: "small"
                                        },
                                        on: {
                                            click: ()=>{
                                                this.jobDel(params.row,params.index)
                                            }
                                        }
                                    },
                                    "删除"
                                )
                            ]);
                        }
                    }
                ],
                data3: [],
                PositionAuthority: [],
                nameValue: '',                    //添加分公司的input信息。
                positionInfo: [],
                gsArr: [],                      //公司
                zwArr: [],
                bmArr:[],                    //职位
                sexArr: [
                    {value: "M",label: "男"},
                    {value: "F",label: "女"}
                ],
                data4: [],
                data5: [],
                data6: [],
                userAddId:'',
                quanxian:'',
                xinyongma:{
                    NameAbbreviation:'',
                    Code:''
                },
                LogoFile: '',
            };
        },
        mounted() {
            this.shishi = libs.uploads2();
            this.$post('UploadExecutor.getSessionID',{}).then(res=>{
                this.sessionId = res.SessionID
                // console.log(res)
            })
            //获取机构缩写
            axios.post('/companyQualifications/findOne').then(res=>{
                this.xinyongma.NameAbbreviation=res.qualifications.NameAbbreviation;
                this.xinyongma.Code=res.qualifications.Code;
            }).catch((err)=>{

            })
            //获取登录人所有的信息
            axios.post("/member/findOne").then((res) => {
                }).catch((err) => {
                })
                if(this.$route.params.name=='name2') {
                    this.tabName = 'name2'
                }
                // 调用树组件信息
                this. getMenu();

                // 获取机构信息
                axios.post("/branch/findMechanism",{
                }).then(res => {
                    if (res._STATUS == 1) {
                        // this.handleSuccessTwo(res.company.ID)
                        // this.scanningCopyDataR.Id = res.company.ID
                        // this.scanningCopyDataL.Id = res.company.ID
                        this.jigouxinxi = res.company
                        this.jigouxinxi.QualificationType = this.jigouxinxi.QualificationType.replace(/。/g, '<br/>')
                    }else{
                            this.handleExcuseTwo()
                        }
                }).catch(res=>{

                })
                // 获取个人信息信息ya呀
                axios.post("/branch/findMember").then(res => {
                    this.peopledata=res.member;                                  ////个人信息
                    console.log(res)
                    if(res.member.LogoFile != null &&res.member.LogoFile != ''){
                            this.LogoFile = 'https://static.anhuanjia.com/avatar/'+ res.member.LogoFile + '?x-oss-process=image/resize,m_fill,h_96,w_96&' + new Date().getTime()
                    }else{
                            this.LogoFile ='https://static.anhuanjia.com/avatar/default.png?x-oss-process=image/resize,m_fill,h_96,w_96'
                    }
                    this.quanxian=localStorage.getItem("userOrg");
                })
                // 人员管理人员表
                axios.get('basicInformation/positionList').then((res)=>{
                    this.positionInfo = res.branchList;
                }).catch((err)=>{
                })
                this.lookUpInfo();
                this.uploadList = this.$refs.upload.fileList;
            },
        methods: {
            handleExcuseTwo(){
                if(this.bgImgL == ''){
                    this.bgImgL = "https://ahj-storage-test.oss-cn-beijing.aliyuncs.com/pcfile/2019-1/205e8%E5%B0%8F%E4%B8%81.png?Expires=33083706758&OSSAccessKeyId=LTAIBhKyqEQAbw7q&Signature=fj%2BJAnnW8aaCyUNfQ6tXBmLE3Rk%3D"
                }
                if(this.bgImgR == ''){
                    this.bgImgR = "https://ahj-storage-test.oss-cn-beijing.aliyuncs.com/pcfile/2019-1/205e8%E5%B0%8F%E4%B8%81.png?Expires=33083706758&OSSAccessKeyId=LTAIBhKyqEQAbw7q&Signature=fj%2BJAnnW8aaCyUNfQ6tXBmLE3Rk%3D"
                }
            },
            // handleSuccessTwo(typeId){
            //     this.$post('fileUpload/initCompanyCertificate',{
                    
            //     }).then(res=>{
            //         console.log(res)
            //         if(res.data){
            //             for(var i = 0;i<res.data.length;i++){
            //                 console.log(res.data[i].CoverFilePath)
            //                 if(res.data[i].IdentityType == '04'){
            //                     this.bgImgL = res.data[i].CoverFilePath
            //                 }else if(res.data[i].IdentityType == '05'){
            //                     this.bgImgR = res.data[i].CoverFilePath
            //                 }else{
            //                     this.bgImgL = "https://ahj-storage-test.oss-cn-beijing.aliyuncs.com/pcfile/2019-1/205e8%E5%B0%8F%E4%B8%81.png?Expires=33083706758&OSSAccessKeyId=LTAIBhKyqEQAbw7q&Signature=fj%2BJAnnW8aaCyUNfQ6tXBmLE3Rk%3D"
            //                     this.bgImgR = "https://ahj-storage-test.oss-cn-beijing.aliyuncs.com/pcfile/2019-1/205e8%E5%B0%8F%E4%B8%81.png?Expires=33083706758&OSSAccessKeyId=LTAIBhKyqEQAbw7q&Signature=fj%2BJAnnW8aaCyUNfQ6tXBmLE3Rk%3D"
            //                 }
            //             }
            //         }else{
            //             if(this.bgImgL == ''){
            //                 this.bgImgL = "https://ahj-storage-test.oss-cn-beijing.aliyuncs.com/pcfile/2019-1/205e8%E5%B0%8F%E4%B8%81.png?Expires=33083706758&OSSAccessKeyId=LTAIBhKyqEQAbw7q&Signature=fj%2BJAnnW8aaCyUNfQ6tXBmLE3Rk%3D"
            //             }
            //             if(this.bgImgR == ''){
            //                 this.bgImgR = "https://ahj-storage-test.oss-cn-beijing.aliyuncs.com/pcfile/2019-1/205e8%E5%B0%8F%E4%B8%81.png?Expires=33083706758&OSSAccessKeyId=LTAIBhKyqEQAbw7q&Signature=fj%2BJAnnW8aaCyUNfQ6tXBmLE3Rk%3D"
            //             }
            //         }
            //     })
            // },
            // 关闭添加人员模态框
            checkOk() {
              this.jigouxinxi.QualificationTypeTemp = this.gradeA.join(',')+','+this.gradeB.join(',')+','+this.gradeC.join(',')
              this.jigouxinxi.QualificationType = '环境影响报告书甲级类别：'+this.gradeA.join(',')+' 环境影响报告书乙级类别：'+this.gradeB.join(',')+' 环境影响报告表类别：'+this.gradeC.join(',')
              this.submit()
            },
            // 创建部门
            getbumen(){
              this.chuangjianbumen=true ;
            },
            checkModalInfo() {
              axios.get('/qualification/findQualifications').then(res=>{
                if(res._STATUS==1) {
                  this.CheckAllInfo = res.map
                  this.checkModal = true
                }
              }).catch(err=>{
              })
            },
            handleView (name) {
                this.imgName = name;
                this.visible = true;
            },
            handleRemove (file) {
                const fileList = this.$refs.upload.fileList;
                this.$refs.upload.fileList.splice(fileList.indexOf(file), 1);
            },
            handleSuccess (response,file,fileList) {
                axios.post('/branch/findMember').then(data=>{
                    console.log('data',data.member.LogoFile)
                    // this.LogoFile = ''
                    // console.log('https://static.anhuanjia.com/avatar/'+ res.member.LogoFile + '?x-oss-process=image/resize,m_fill,h_96,w_96')
                    // if(res.member.LogoFile != null && res.member.LogoFile != ''){
                    this.LogoFile = "https://static.anhuanjia.com/avatar/"+ data.member.LogoFile + "?x-oss-process=image/resize,m_fill,h_96,w_96&" + new Date().getTime()
                    this.$store.commit('setUserHead','https://static.anhuanjia.com/avatar/'+ data.member.LogoFile + '?x-oss-process=image/resize,m_fill,h_96,w_96&' + new Date().getTime())
                    // this.reload()
                        // https://static.anhuanjia.com/avatar/4bafd56228f84a1a9563ef20e9fba999.jpg?x-oss-process=image/resize,m_fill,h_96,w_96
                        // this.$store.state.picAdd = 'https://static.anhuanjia.com/avatar/'+ res.member.LogoFile + '?x-oss-process=image/resize,m_fill,h_96,w_96'
                    // }else{
                    //     this.LogoFile ='https://static.anhuanjia.com/avatar/default.png?x-oss-process=image/resize,m_fill,h_96,w_96'
                    // }
               }).catch(err=>{})
            },
            handleFormatError (file) {
                this.$Notice.warning({
                    title: '文件格式不正确',
                    desc:  file.name + '，文件格式不正确, 请选择 jpg 或 png.'
                });
            },
            handleMaxSize (file) {
                this.$Notice.warning({
                    title: '超过文件大小限制',
                    desc: '文件  ' + file.name + ' 太大, 上传文件大小不得超过20M.'
                });
            },
            handleBeforeUpload () {
                const check = this.uploadList.length < 1;
                if (!check) {
                    this.$Notice.warning({
                        title: '已有头像.'
                    });
                }
                return check;
            },
            // 人员手机号查询
            searchphone(){
                if(this.formCustom.passwd.length != 11){
                    this.$Message.error("请输入正确的手机格式")
                    return false
                }
                axios.post('/basicInformation/addMember',{
                    UserName:this.formCustom.passwd
                }).then((res)=>{
                    if(res._MESSAGE=="该账号未创建"){
                        this.chuangjianrenyuan=true;
                        this.tianjiarenyuan=false;
                    }else if(res._MESSAGE=="该账号已属于本公司"){
                        this.$Message.success('该账号已属于本公司')
                    }else if(res._MESSAGE=="该账号已属于其他公司"){
                        this.$Message.success('该账号已属于其他公司')
                    }else if(res._MESSAGE=="请联系管理员设置该一级账号下二级账号数量！"){
                        this.$Message.success('请联系管理员设置该一级账号下二级账号数量！')
                    }else if(res._MESSAGE=="该一级账号下的二级账号已达到上限，无法添加新的账号"){
                        this.$Message.success('该一级账号下的二级账号已达到上限，无法添加新的账号')
                    }else{
                        this.tianjiarenyuan=true;
                        this.chuangjianrenyuan=false;
                        this.userAddId=res.user.ID
                    }
                }).catch((err)=>{
                })
            },
            // 根据手机号创建人员
            chuangjianperson(){
                axios.post('/basicInformation/addMember',{
                    UserName:this.formCustom.passwd,
                    Build:'0'
                }).then((res)=>{
                    if(res._STATUS==1){
                    this.$Message.success(res._MESSAGE);
                    this.lookUpInfo()
                    }
                    }).catch((err)=>{
                })
            },
            addperson(){         // 根据手机号添加人员
                axios.post('/basicInformation/addMember',{
                    UserName:this.formCustom.passwd,
                    MemberId:this.userAddId,
                    Build:'1'
                }).then((res)=>{
                    this.$Message.success(res._MESSAGE);
                    this.lookUpInfo()
                }).catch((err)=>{
                })
            },
            // 组织架构tree组件
            getMenu(){
                this.$post('branch.getMenus',{}).then((res)=>{
                    for(let i=0;i<res.branchTree.length;i++){
                        res.branchTree[i].expand=true;
                        for(let j=0;j<res.branchTree[i].children.length;j++){
                            res.branchTree[i].children[j].expand=true;
                        }
                    }
                    this.tree=res.branchTree;
                    //公司的id
                    localStorage.setItem('company',res.branchTree[0].company)
                    localStorage.setItem('id',res.branchTree[0].id)
                    }).catch((err)=>{
                })
            },
            // 修改机构信息
            submit(){
                this.$refs['jigouxinxi'].validate((valid) => {
                    if (valid) {
                       let info = this.jigouxinxi
                       info.QualificationType=''
                        axios.post('branch/updateMechanism',info).then((res)=>{
                            this.$Message.success('修改机构信息成功');
                            // 获取机构信息
                            axios.post("/branch/findMechanism",{
                            }).then(res => {
                                this.jigouxinxi=res.company
                                this.jigouxinxi.QualificationType = this.jigouxinxi.QualificationType.replace(/。/g,'<br/>')
                            }).catch(err=>{
                            })
                        });
                        axios.post('companyQualifications/saveOrUdate',this.xinyongma).then(res=>{
                        })
                    } else {
                        this.$Message.error('请输入正确信息');
                    }
                })
            },
            //修改个人信息
            modifyperson(){
                this.$refs['gerenxinxi'].validate((valid) => {
                    if (valid) {
                        // this.peopledata.Prop1 = '';
                        axios.post('branch/updateMember',this.peopledata).then((res)=>{
                            if(res._STATUS==1) {
                                this.$Message.success(res._MESSAGE);
                            }
                        }).catch((err)=>{
                        })
                    } else {
                        this.$Message.error('请输入正确信息');
                    }
                })

            },
            dialog(type) {
                const title = "个人信息修改成功";
                const content = "<p>3s后自动退出</p>";
                this.$Modal.success({
                    title: title,
                    content: content
                });
                setTimeout(() => {
                    this.$Modal.remove();
                }, 3000);
            },
            ok() {
                this.instance()
            },
            phone(type) {
                const title = '手机号绑定成功';
                const content = '<p>3s后自动自动退出</p>';
                this.$Modal.success({
                    title: title,
                    content: content
                });
                setTimeout(() => {
                    this.$Modal.remove();
                }, 3000);
            },
            cancel() {
                this.$Message.info('Clicked cancel');
            },
            append (data,newData) {
                const children = data.children || [];
                children.push({
                    id:newData.ID,
                    title: newData.Name,
                    expand: true
                });
                this.$set(newData, 'children', children);
            },
            remove (root, node, data) {
                const parentKey = root.find(el => el === node).parent;
                const parent = root.find(el => el.nodeKey === parentKey).node;
                const index = parent.children.indexOf(data);
                parent.children.splice(index, 1);
            },
            lookUpInfo(num){
                this.loading=true
                // console.log(this.look)
                this.$post('ProjectInfo.findInformation',{
                    RealName: this.look.realName.trim(),    //加上去除空格方法，防止多加空格搜索不到结果
                    Name: this.look.name,
                    Position: this.look.position,
                    userOrg: localStorage.getItem("userOrg"),
                    PageIndex: num? num-1:this.page-1
                }).then((res)=>{
                    // console.log(res)
                    this.bmArr=res.branch
                    this.pageTotal=res.num
                    // 如果所属公司为空话，职位不能出禁选的情况
                    if(res.information&&res.information.length>0) {
                        res.information = res.information.map(el=>{
                            if(!el.gsId) {
                                el.companyType = null
                            }
                            return el
                        })
                    }
                    this.data1 = res.information
                    this.zwArr = res.position
                    this.gsArr = res.company
                    this.loading=false
                    
                    this.page = num? num:this.page;
                     
                   
                }).catch((err)=>{
                })
            },
            // tree组件的render函数
            renderContent1 (h, { root, node, data }) {
                if(data.companyType==0){
                    return h('span', {
                        style: {
                            display: 'inline-block',
                            width: '100%'
                        }
                    }, [
                        h('span', [
                            h('Icon', {
                                props: {
                                    type: 'ios-home'
                                },
                                style: {
                                    marginRight: '8px'
                                }
                            }),
                            h('span', data.title)
                        ]),
                        h('span', {
                            style: {
                                display: 'inline-block',
                                float: 'right',
                                marginRight: '32px'
                            }
                        }, [
                            h('Button', {
                                props: Object.assign({}, this.buttonProps, {
                                    icon: 'md-add',
                                    type: 'primary'
                                }),
                                style: {
                                    width: '64px'
                                },
                                on: {
                                    click: () => {
                                        this.$Modal.confirm({
                                            render: (h) => {
                                                return h('Input', {
                                                    props: {
                                                        value: this.nameValue,
                                                        autofocus: true,
                                                        placeholder: '请输入分公司名字'
                                                    },
                                                    on: {
                                                        input: (val) => {
                                                            this.nameValue = event.target.value;
                                                            // this.nameValue = val;
                                                        },
                                                    },
                                                })
                                            },
                                            onOk: () => {
                                                this.$post('MemberBranch.add',{
                                                    Name:this.nameValue,
                                                    CompanyType:1,
                                                    Company:data.company,
                                                    ParentInnerCode:data.id,
                                                    Type:'1',
                                                    OrderFlag:'0',
                                                    TreeLevel:'0'
                                                }).then((res)=>{
                                                    if(res._STATUS == 1){
                                                        this.$Message.success(res._MESSAGE);
                                                        this.getMenu();
                                                    }else if(res._STATUS == 0){
                                                        this.$Message.error(res._MESSAGE);
                                                    }else{
                                                        this.$Message.error(res._MESSAGE);
                                                    }
                                                    this.nameValue = ''
                                                }).catch((err)=>{console.log(err)})
                                            }
                                        })
                                    }
                                }
                            })
                        ])
                    ]);
                }else if(data.companyType==2){
                        return h('span', {
                        style: {
                            display: 'inline-block',
                            width: '100%'
                        }
                    }, [
                        h('span', [
                            h('Icon', {
                                props: {
                                    type: 'md-folder'
                                },
                                style: {
                                    marginRight: '8px'
                                }
                            }),
                            h('span', data.title)
                        ]),
                        h('span', {
                            style: {
                                display: 'inline-block',
                                float: 'right',
                                marginRight: '32px'
                            }
                        }, [

                            h('Button', {
                                props: Object.assign({}, this.buttonProps, {
                                    icon: 'md-remove'
                                }),
                                on: {
                                    // 删除分公司
                                    click: () => {
                                    this.$Modal.confirm({
                                        title: '提示',
                                        content: '<p>是否删除该部门</p>',
                                        onOk: () => {
                                        axios.post('branch/deleteBranch',
                                            {
                                            Id:data.id,
                                            }
                                        ).then((res)=>{
                                            if(res._STATUS == 1){
                                                this.remove(root, node, data)
                                                this.$Message.success('删除部门成功');
                                            }else{
                                                this.$Message.error('删除失败')
                                            }
                                        })
                                        },
                                        onCancel: () => {
                                            this.$Message.info('Clicked cancel');
                                        }
                                    });
                                    }
                                }
                            })
                        ])
                    ]);
                }else{
                        return h('span', {
                        style: {
                            display: 'inline-block',
                            width: '100%'
                        }
                    }, [
                        h('span', [
                            h('Icon', {
                                props: {
                                    type: 'md-home'
                                },
                                style: {
                                    marginRight: '8px'
                                }
                            }),
                            h('span', data.title)
                        ]),
                        h('span', {
                            style: {
                                display: 'inline-block',
                                float: 'right',
                                marginRight: '32px'
                            }
                        }, [
                            h('Button', {
                                props: Object.assign({}, this.buttonProps, {
                                    icon: 'md-add'
                                }),
                                style: {
                                    marginRight: '8px'
                                },
                                on: {
                                    click: () => {
                                        this.$Modal.confirm({
                                            render: (h) => {
                                                return h('Input', {
                                                    props: {
                                                        value: this.nameValue,
                                                        autofocus: true,
                                                        placeholder: '请输入部门名称'
                                                    },
                                                    on: {
                                                        input: (val) => {
                                                            if(val.data){
                                                                this.nameValue = val.data;
                                                            }else{
                                                                this.nameValue = val;
                                                            }
                                                            // this.nameValue = val;
                                                        },
                                                    },
                                                })
                                            },
                                            onOk: () => {
                                                this.$post('MemberBranch.add',{
                                                    Name:this.nameValue,
                                                    CompanyType:2,
                                                    Company:data.company,
                                                    ParentInnerCode:data.id,
                                                    Type:'2',
                                                    OrderFlag:'0',
                                                    TreeLevel:'0'
                                                }).then(res =>{
                                                    if(res._STATUS == 0){
                                                        this.$Message.error(res._MESSAGE)
                                                    }else if(res._STATUS == 1){
                                                        this.getMenu();
                                                        this.$Message.success(res._MESSAGE)
                                                    }else{
                                                        this.getMenu();
                                                    }
                                                    this.nameValue = ''
                                                }).catch((err)=>{
                                                })
                                            }
                                        })


                                    }
                                }
                            }),
                            h('Button', {
                                props: Object.assign({}, this.buttonProps, {
                                    icon: 'md-remove'
                                }),
                                on: {
                                    // 删除分公司
                                    click: () => {
                                    this.$Modal.confirm({
                                        title: '提示',
                                        content: '<p>是否删除该分公司</p>',
                                        onOk: () => {
                                        axios.post('branch/deleteBranch',
                                            {
                                            Id:data.id,
                                            }
                                        ).then((res)=>{
                                            this.remove(root, node, data)
                                            this.$Message.success('删除分公司成功');
                                        })
                                        },
                                        onCancel: () => {
                                            this.$Message.info('Clicked cancel');
                                        }
                                    });
                                    }
                                }
                            })
                        ])
                    ]);
                }
            },
            renderContentquanxian (h, { root, node, data }) {//树组件二级账号用此数据
                if(data.companyType==0){
                    return h('span', {
                        style: {
                            display: 'inline-block',
                            width: '100%'
                        }
                    }, [
                        h('span', [
                            h('Icon', {
                                props: {
                                    type: 'ios-home'
                                },
                                style: {
                                    marginRight: '8px'
                                }
                            }),
                            h('span', data.title)
                        ]),
                        h('span', {
                            style: {
                                display: 'inline-block',
                                float: 'right',
                                marginRight: '32px'
                            }
                        }, [
                            h('Button', {
                                props: Object.assign({}, this.buttonProps, {
                                    icon: 'ios-add',
                                    type: 'primary',
                                    disabled:true
                                }),
                                style: {
                                    width: '64px'
                                },
                                on: {
                                    click: () => {
                                        this.$Modal.confirm({
                                            render: (h) => {
                                                return h('Input', {
                                                    props: {
                                                        value: this.nameValue,
                                                        autofocus: true,
                                                        placeholder: '请输入分公司名字'
                                                    },
                                                    on: {
                                                        input: (val) => {
                                                            if(val.data){
                                                                this.nameValue = val.data;
                                                            }else{
                                                                this.nameValue = val;
                                                            }
                                                            // this.nameValue = val;
                                                        },
                                                    },
                                                })
                                            },
                                            onOk: () => {
                                                this.$post('MemberBranch.add',{
                                                    Name:this.nameValue,
                                                    CompanyType:1,
                                                    Company:data.company,
                                                    ParentInnerCode:data.id,
                                                    Type:'1',
                                                    OrderFlag:'0',
                                                    TreeLevel:'0'
                                                }
                                                ).then((res)=>{
                                                    this.nameValue = ''
                                                   this.getMenu();
                                                    this.$Message.success('添加分公司成功');
                                                })
                                            }
                                        })
                                    }
                                }
                            })
                        ])
                    ]);
                }else if(data.companyType==2){
                        return h('span', {
                        style: {
                            display: 'inline-block',
                            width: '100%'
                        }
                    }, [
                        h('span', [
                            h('Icon', {
                                props: {
                                    type: 'ios-folder-outline'
                                },
                                style: {
                                    marginRight: '8px'
                                }
                            }),
                            h('span', data.title)
                        ]),
                        h('span', {
                            style: {
                                display: 'inline-block',
                                float: 'right',
                                marginRight: '32px'
                            }
                        }, [

                            h('Button', {
                                props: Object.assign({}, this.buttonProps, {
                                    icon: 'ios-remove',
                                    disabled:true
                                }),
                                on: {
                                    // 删除分公司
                                    click: () => {
                                    this.$Modal.confirm({
                                        title: '提示',
                                        content: '<p>是否删除该部门</p>',
                                        onOk: () => {
                                        axios.post('branch/deleteBranch',
                                            {
                                            Id:data.id,
                                            }
                                        ).then((res)=>{
                                            if(res._STATUS == 1){
                                                this.remove(root, node, data)
                                                this.$Message.success('删除部门成功');
                                            }else{
                                                this.$Message.error('删除失败')
                                            }
                                        })
                                        },
                                        onCancel: () => {
                                            this.$Message.info('Clicked cancel');
                                        }
                                    });
                                    }
                                }
                            })
                        ])
                    ]);
                }else{
                        return h('span', {
                        style: {
                            display: 'inline-block',
                            width: '100%'
                        }
                    }, [
                        h('span', [
                            h('Icon', {
                                props: {
                                    type: 'ios-home-outline'
                                },
                                style: {
                                    marginRight: '8px'
                                }
                            }),
                            h('span', data.title)
                        ]),
                        h('span', {
                            style: {
                                display: 'inline-block',
                                float: 'right',
                                marginRight: '32px'
                            }
                        }, [
                            h('Button', {
                                props: Object.assign({}, this.buttonProps, {
                                    icon: 'ios-add',
                                    disabled:true
                                }),
                                style: {
                                    marginRight: '8px'
                                },
                                on: {
                                    click: () => {
                                        this.$Modal.confirm({
                                            render: (h) => {
                                                return h('Input', {
                                                    props: {
                                                        value: this.nameValue,
                                                        autofocus: true,
                                                        placeholder: '请输入部门名称'
                                                    },
                                                    on: {
                                                        input: (val) => {
                                                            if(val.data){
                                                                this.nameValue = val.data;
                                                            }else{
                                                                this.nameValue = val;
                                                            }
                                                            // this.nameValue = val;
                                                        },
                                                    },
                                                })
                                            },
                                            onOk: () => {
                                                this.$post('MemberBranch.add',{
                                                    Name:this.nameValue,
                                                    CompanyType:2,
                                                    Company:data.company,
                                                    ParentInnerCode:data.id,
                                                    Type:'2',
                                                    OrderFlag:'0',
                                                    TreeLevel:'0'
                                                }).then(res =>{
                                                    this.getMenu();
                                                    this.nameValue = ''
                                                    this.$Message.success('添加部门成功');
                                                }).catch((err)=>{
                                                })
                                        }
                                        })
                                    }
                                }
                            }),
                            h('Button', {
                                props: Object.assign({}, this.buttonProps, {
                                    icon: 'ios-remove',
                                    disabled:true
                                }),
                                on: {
                                    // 删除分公司
                                    click: () => {
                                    this.$Modal.confirm({
                                        title: '提示',
                                        content: '<p>是否删除该分公司</p>',
                                        onOk: () => {
                                        axios.post('branch/deleteBranch',
                                            {
                                            Id:data.id,
                                            }
                                        ).then((res)=>{
                                            this.remove(root, node, data)
                                            this.$Message.success('删除分公司成功');
                                        })
                                        },
                                        onCancel: () => {
                                            this.$Message.info('Clicked cancel');
                                        }
                                    });
                                    }
                                }
                            })
                        ])
                    ]);
                }
            },
            newPosition(){
                this.chuangjianzhiwei=true
                axios.get('basicInformation/branchList').then((res)=>{
                    this.data3 = res.newBranch
                    // this.PositionAuthority = res.oldBranch
                    // 已有的职位默认禁选
                    if(res.oldBranch&&res.oldBranch.length>0) {
                      this.PositionAuthority=res.oldBranch.map(e=>{
                        e.disabled = false
                        if(res.newBranch&&res.newBranch.length>0) {
                          res.newBranch.forEach(element => {
                            if(element.ParentId==e.Id) {
                              e.disabled = true
                            }
                          });
                        }
                        return e
                      })
                    }
                })
                .catch((err)=>{
                })
            },
            clearInfo(){            //人员管理清除
                this.look.realName = ''
                this.look.position= ''
                this.look.name = ''
                this.lookUpInfo()
            },
            bcBtn(data){               //保存人员
                let realName = this.columns1RealName
                if(realName) {
                    data.realName = realName
                }
                // let newData = data;
                // newData.BranchInnerCode = data.branchList
                if(!data.positionId) {
                  this.$Message.error('请选择职位名称！')
                  return
                }else if(!data.branchInnerCode) {
                  this.$Message.error('请选所属部门！')
                  return
                }else if(!data.realName) {
                  this.$Message.error('姓名不能为空！')
                  return
                }
                var ajaxData = {
                  MemberId: data.memberId,  //用户
                  PositionId: data.positionId,  //职位名称
                  BranchInnerCode: data.branchInnerCode,  //所属部门
                  RealName: data.realName,  //姓名
                  Sex: data.sex //性别
                }
                axios.post('basicInformation/updateInformation',ajaxData).then(res=>{
                  if(res._STATUS==1) {
                    this.$Message.success(res._MESSAGE)
                    this.lookUpInfo()
                  }else {
                    this.$Message.error(res._MESSAGE)
                  }
                })
            },
            scBtn(data){            //人员删除
                axios.post('basicInformation/deleteInformation',{
                    MemberId: data.memberId
                }).then((res)=>{
                    if(res._STATUS==1){
                        this.$Message.success(res._MESSAGE);
                        this.lookUpInfo()
                    }else if(res._STATUS == 0){
                        this.deleteMsg = res._MESSAGE
                        this.deleteBtn = true
                        // this.$Modal.warning({
                        //     title: '提示',
                        //     content: res._MESSAGE
                        // })
                    }
                })
            },
            deleteOk(){
                
            },
            czBtn(data){//重置密码
                axios.post('branch/resetPassword',{
                    Id: data.memberId
                }).then((res)=>{
                    if(res._STATUS==1){
                        this.$Message.success(res._MESSAGE)
                    }
                }).catch((err)=>{
                })
            },
            addBtn(){
                let info = {
                    Id: '',
                    ParentId: '',
                    Position: '',
                    Type: ''
                }
                this.data3.push(info)
            },
            jobAdd(data){
                //职位添加保存
                if(data.Id){
                    axios.post('basicInformation/saveOrUpdate',{
                        ParentId: data.ParentId,
                        Position: data.Position
                    }).then((res)=>{
                        this.newPosition();
                    })
                }else{
                    if(data.ParentId){
                        axios.post('basicInformation/saveOrUpdate',{
                            ParentId: data.ParentId,
                            Position: data.Position
                        }).then((res)=>{
                            if(res._STATUS == 1){
                                this.$Message.info('添加成功')
                                this.newPosition();
                                this.lookUpInfo(1)  //成功后人员表格数据要刷新
                            }else{
                                this.$Message.error(res._MESSAGE)
                            }
                        }).catch((err)=>{
                            this.$Message.error('添加失败')
                        })
                    }else{
                        this.$Message.error('请选择职位')
                    }
                }
            },
            jobDel(data,index){                      //职位删除
                axios.post('basicInformation/deletePosation',{
                    PositionId: data.Id,
                }).then((res)=>{
                    console.log(res)
                    if(res._STATUS == 1){
                        this.$Message.info('删除成功')
                        this.data3.splice(index,1)
                        this.lookUpInfo(1)  //成功后人员表格数据要刷新
                    }else{
                        this.$Message.error('你还未点保存！')
                    }
                }).catch((err)=>{
                    console.log(err)
                })
            },
            changePage(page){
                this.page = page;
                console.log(this.page);
                this.lookUpInfo()
            }
        },
        watch:{
            addpeople(val){
                if(this.addpeople==false){
                    this.chuangjianrenyuan=false
                    this.tianjiarenyuan=false
                }
            }
        }
    };
</script>
<style lang="less" scoped>
    .area {
        width: 100%;
        height: 100%;
        background: #f3f3f4;
        padding: 2% 3%;
        margin-top: 10px;
        .ivu-radio-group{
            margin-left: 11px;
        }
    }
    .changemob{
        margin-top: 10px;
        margin-left: 255px;
    }
    .dis {
        display: inline-block;
        width: 100%;
        height: 300px;
        background: #c1c1c1;
    }

    .fon {
        font-weight: bold;
        margin-bottom: 1%;
    }
  /deep/  .ivu-modal-body{

        .phone{
            margin-bottom: 10px;
        }
        .code{
            display: inline-block;
            width: 224px;
      }
    }
    .renyuan{
        margin-top: 20px;
        text-align: center;
        span{
            display: inline-block;
            display: inline-block;
            width: 300px;
            text-align: left;
        }
    }
    // /deep/.ivu-input[disabled], fieldset[disabled] .ivu-input{
    //     color: black !important;
    // }
    .demo-upload-list{
        display: inline-block;
        width: 60px;
        height: 60px;
        text-align: center;
        line-height: 60px;
        border: 1px solid transparent;
        border-radius: 4px;
        overflow: hidden;
        background: #fff;
        position: relative;
        box-shadow: 0 1px 1px rgba(0,0,0,.2);
        margin-right: 4px;
    }
    .demo-upload-list img{
        width: 100%;
        height: 100%;
    }
    .demo-upload-list-cover{
        display: none;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0,0,0,.6);
    }
    .demo-upload-list:hover .demo-upload-list-cover{
        display: block;
    }
    .demo-upload-list-cover i{
        color: #fff;
        font-size: 20px;
        cursor: pointer;
        margin: 0 2px;
    }
    .tooltip.ivu-tooltip{
      /deep/.ivu-tooltip-rel{
        width: 100%;
      }
    }
    .scanningCopy{
        width: 100%;
        height: 300px;
        background-position: 0 0;
        background-size: 100% 100%;
    }
    .ivu-form-item-error-tip{
        top: 100%;
        left: 0;
    }
</style>
